<?php
/*
+--------------------------------------------------------------------------
|   AffiliStore 2
|   ========================================
|   Web: http://www.affilistore.com
|   Email: admin (at) affilistore (dot) com
|	License Type: AffiliStore 2 is NOT open source software and limitations apply 
|   Licence Info: Visit AffiliStore website and click on 'Licence'
+--------------------------------------------------------------------------
*/
require_once('../includes/connect.php');
require_once('../includes/functions.php');

mysql_select_db($database, $databaseConnect);

// get navigation options
$getNavOpt = mysql_query("SELECT * FROM affiliSt_config WHERE name = 'navOptions'");
$navOpt = mysql_fetch_assoc($getNavOpt);
$navOpt = explode(":", $navOpt['value']);

// get website title
$getWebTitle = mysql_query("SELECT * FROM affiliSt_config WHERE name = 'adWebTitle'");
$webTitle = mysql_fetch_assoc($getWebTitle);
// get website strapline
$getWebStrap = mysql_query("SELECT * FROM affiliSt_config WHERE name = 'adWebStrap'");
$webStrap = mysql_fetch_assoc($getWebStrap);
// get install directory
$getInstallDir = mysql_query("SELECT * FROM affiliSt_config WHERE name = 'installDir'");
$installDir = mysql_fetch_assoc($getInstallDir);


// popular products listing
$getPopular = mysql_query("SELECT * FROM affiliSt_products1 ORDER BY prodPopularity DESC LIMIT 0, 10");
$popularList = mysql_fetch_assoc($getPopular);

echo '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">';
?>


<channel>

<title><?php echo $webTitle['value'].' Popular Products'; ?></title>
<description><?php echo $webStrap['value']; ?></description>
<link><?php echo $installDir['value']; ?></link>

<?php do { ?>

<item>
<title><?php echo $popularList['prodName']; ?></title>
<description><?php echo substr(strip_tags($popularList['prodDescription']), 0, 150).'...'; ?></description>
<link><?php 
		
// use merchant product ids
if ($navOpt[12] == 1) {
$theprodID = $popularList['merchantProdID'];
} else {
$theprodID = $popularList['prodID'];
					}
if ($navOpt[7] == 1) {
// html perma
echo $installDir['value'].'product/'.$popularList['prodDB'].'/'.$theprodID.'/'.urltxt($popularList['prodName']).'.html';
} else {
// php link
echo $installDir['value'].'index.php?case=product&proddb='.$popularList['prodDB'].'&pid='.$theprodID;
} ?></link>
</item>

<?php } while ($popularList = mysql_fetch_assoc($getPopular)); ?>



</channel>

</rss>